package domain.valueObejcts;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;

@Entity
public class ProjectPosition implements Serializable {

	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	@SequenceGenerator(name = "position_gen", sequenceName = "position_id_seq")
	private int id;
	private String dateString;
	private Date date;
	@OneToOne
	@JoinColumn
	private Floor floor;
	@ManyToOne
	@JoinColumn
	private Location location;
	@OneToOne
	@JoinColumn
	private Employee employee;
	private int minutesPlaned;
	private int minutesWorked;
	@ManyToOne
	@JoinColumn
	private Project project;
	
	public ProjectPosition(){
		
	}
	
	public int getId(){
		return this.id;
	}
	public void setId(int id){
		this.id = id;
	}
	public String getDateString() {
		return dateString;
	}
	public void setDateString(String dateString) {
		this.dateString = dateString;
	}
	public Date getDate() {
		return date;
	}
	public void setDate(Date date) {
		this.date = date;
	}
	public Location getLocation() {
		return location;
	}
	public void setLocation(Location location) {
		this.location = location;
	}
	public Employee getEmployee() {
		return employee;
	}
	public void setEmployee(Employee employee) {
		this.employee = employee;
	}
	public int getMinutesPlaned() {
		return minutesPlaned;
	}
	public void setMinutesPlaned(int minutesPlaned) {
		this.minutesPlaned = minutesPlaned;
	}
	public int getMinutesWorked() {
		return minutesWorked;
	}
	public void setMinutesWorked(int minutesWorked) {
		this.minutesWorked = minutesWorked;
	}
	public Floor getFloor() {
		return floor;
	}
	public void setFloor(Floor floor) {
		this.floor = floor;
	}
	public void setProject(Project project) {
		this.project = project;
	}
	public Project getProject(Project project) {
		return project;
	}
	public String getWorked() {
		int hours = minutesWorked / 60;
		int minutes = minutesWorked % 60;
		return hours + "h" + minutes + "m";
	}
	public String getPlaned() {
		int hours = minutesPlaned / 60;
		int minutes = minutesPlaned % 60;
		return hours + "h" + minutes + "m";
	}
	
}
